package com.game.battleship.adapters;


import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;

import com.game.battleship.R;

public class ArrangeShipsBoardAdapter extends BaseAdapter {

	private static final int CELL_SHIP_HEAD = 2;
	private static final int CELL_SHIP_BODY = 1;
	private static final int CELL_NORMAL = 0;
	
	private Context mContext;
	private int cellSize;
	
	private int[] formation;
	
	public ArrangeShipsBoardAdapter(Context context, int size, int[] f) {
		super();
		mContext = context;
		cellSize = size;
		formation = f;
	}
	
	
	public int getCount() {
		// TODO Auto-generated method stub
		return 10 * 10;
	}

	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	public View getView(int pos, View view, ViewGroup parent) {
		// TODO Auto-generated method stub
		ImageView imageView = new ImageView(mContext);
		imageView.setLayoutParams(new GridView.LayoutParams(cellSize, cellSize));
		imageView.setScaleType(ScaleType.FIT_XY);
		imageView.setBackgroundColor(Color.TRANSPARENT);
		if (formation[pos] != CELL_NORMAL) {
			if (formation[pos] == CELL_SHIP_BODY) {
				imageView.setImageResource(R.drawable.ship);
			}
			else if (formation[pos] == CELL_SHIP_HEAD) {
				imageView.setImageResource(R.drawable.ship);
			}
		}
		return imageView;
	}

}
